package org.example.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolMemoryId;
import org.apache.commons.lang3.StringUtils;
import org.example.bean.Appointment;
import org.springframework.stereotype.Component;

@Component
public class XiaozhiTools {
    @Tool(name="预约挂号",value = "根据参数先执行工具方法queryDepartment,查询是否可以预约,并直接给用户回答是否可预约,并让用户确认所有预约信息,用户确认后再进行预约.")
    public String bookAppointment(Appointment appointment) {
        System.out.println("开始预约:");
        System.out.println("预约信息:"+appointment);
      if(StringUtils.equals(appointment.getUsername(),"xiaozhi")){
          return "你已经有预约了";
      }
      return "预约成功";
    }
    @Tool(name="queryDepartment查询是否有号源",value = "根据科室名称，日期，时间和医生查询是否有号源，并返回给用户")
    public boolean queryDepartment(@P(value = "科室名称")String name,
                                   @P(value = "日期")String date,
                                   @P(value = "时间, 可选值: 上午,下午")String time,
                                   @P(value = "医生名称",required = false)String doctorName) {
        System.out.println("查询是否有号源:");
        System.out.println("科室名称:"+name);
        System.out.println("日期:"+date);
        System.out.println("时间:"+time);
        System.out.println("医生名称:"+doctorName);
        return true;
    }

    @Tool(name="取消预约挂号",value = "根据参数,查询预约是否存在,如果存在则删除预约记录，并返回取消预约成功，否则返回取消预约。")
    public String cancelAppointment(Appointment appointment) {
        System.out.println("取消预约:");
        System.out.println("取消预约信息:"+appointment);
        if(StringUtils.equals(appointment.getUsername(),"xiaozhi")){
            return "取消预约成功";
        }
        return "你没有预约记录，请核查对预约科室和时间";
    }
}
